import requests
from config import url_cloud,headers_web

class EntranceGuardTemporaryAuthorization:
    def __int__(self):
        self.url = url_cloud
        self.headers = headers_web

    @classmethod
    def get_authorizationstatus(cls,url_cloud: str,params= None,headers= headers_web):
        '''
        summary:接口-获取授权状态
        description:云课堂管理端门禁临时授权使用
        :param url_cloud:
        :param params:
        :param headers:
        :return:
        '''
        url = url_cloud + "/teachinglaboratoryapi/api/v1/entranceguardtemporaryauthorization/status"
        r = requests.get(url=url,headers=headers,params=params)
        return r

    @classmethod
    def get_timeinfo(cls,url_cloud: str,params= None,headers= headers_web):
        '''
        summary:接口-获取授权时间类型和授权的时间段信息
        description:云课堂管理端门禁临时授权使用
        :param url_cloud:
        :param params:
        :param headers:
        :return:
        '''
        url = url_cloud + "/teachinglaboratoryapi/api/v1/entranceguardtemporaryauthorization/timeinfo"
        r = requests.get(url=url,headers=headers,params=params)
        return r

    @classmethod
    def post_addauthorization(cls, url_cloud: str, params=None, headers=headers_web,json = None):
        '''
        summary:创建临时授权
        description:1、云课堂管理端创建临时授权使用
        :param url_cloud:
        :param params:
        :param headers:
        :param json:
        :return:
        '''
        url = url_cloud + "/teachinglaboratoryapi/api/v1/entranceguardtemporaryauthorizations"
        r = requests.post(url=url, headers=headers, params=params,json= json)
        return r

    @classmethod
    def post_cancelauthorization(cls, url_cloud: str, params=None, headers=headers_web,json = None):
        '''
        summary:批量取消临时授权并下发门禁取消记录
        description:1、云课堂管理端取消临时授权使用
        :param url_cloud:
        :param params:
        :param headers:
        :param json:
        :return:
        '''
        url = url_cloud + "/teachinglaboratoryapi/api/v1/entranceguardtemporaryauthorizations/statuses"
        r = requests.post(url=url, headers=headers, params=params,json= json)
        return r

    @classmethod
    def post_searchauthorization(cls, url_cloud: str, params=None, headers=headers_web,json = None):
        '''
        summary:查询临时授权列表
        description:云课堂管理端门禁临时授权使用
        :param url_cloud:
        :param params:
        :param headers:
        :param json:
        :return:
        '''
        url = url_cloud + "/teachinglaboratoryapi/api/v1/entranceguardtemporaryauthorization"
        r = requests.post(url=url, headers=headers, params=params,json= json)
        return r